home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ttedit / dragdrop.bas < prev    next >
BASIC Source File  |  1994-11-28  |  2KB  |  45 lines

  1. Option Explicit
  2.  
  3. Type Msg                'used by peekmessage function
  4.     hWnd As Integer
  5.     message As Integer
  6.     wparam As Integer
  7.     lParam As Long
  8.     time As Long
  9.     PT As PointAPI
  10. End Type
  11.  
  12. Global Const WM_DROPFILES = &H233
  13. Global Const PM_NOREMOVE = 0
  14. Global Const PM_NOYIELD = 2
  15.  
  16. Declare Sub DragAcceptFiles Lib "Shell" (ByVal hWnd As Integer, ByVal Accept As Integer)
  17. Declare Function PeekMessage Lib "User" (lpMsg As Msg, ByVal hWnd As Integer, ByVal wMsgFilterMin As Integer, ByVal wMsgFilterMax As Integer, ByVal wRemoveMsg As Integer) As Integer
  18. Declare Function DragQueryFile Lib "Shell" (ByVal hdrop As Integer, ByVal indexFilenum As Integer, ByVal lpFileName As String, ByVal buffsize As Integer) As Integer
  19. Declare Sub DragFinish Lib "Shell" (ByVal hWnd As Integer)
  20.  
  21. Sub CheckDragDrop (Handle As Integer)
  22.     Dim NewMessage As Msg
  23.     Dim Fname  As String * 129
  24.     Dim X As Integer
  25.     Dim Counter As Integer
  26.     Dim Temp$
  27.     If PeekMessage(NewMessage, Handle, WM_DROPFILES, WM_DROPFILES, PM_NOREMOVE Or PM_NOYIELD) Then
  28.     'Get number of files dropped
  29.     X = DragQueryFile(NewMessage.wparam, True, Fname, 128)
  30.     For Counter = 0 To X - 1   ' for each file dropped
  31.         If DragQueryFile(NewMessage.wparam, Counter, Fname, 128) Then
  32.         End If
  33.         Temp$ = OpenFile(Fname)
  34.         If Len(Temp$) Then
  35.            Call NewFile
  36.            MDI.ActiveForm.Caption = Fname
  37.            MDI.ActiveForm.txtTextEdit = Temp$
  38.         End If
  39.     Next
  40.      'call dragfinish to release d/d memory buffer
  41.     DragFinish NewMessage.wparam
  42.     End If
  43. End Sub
  44.  
  45.